package commonAdmin.web;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import commonAdmin.domain.LoginForm;

/**
 * 
 * @author ming.chen
 *
 */
@Controller
public class LoginController {

	@Autowired
	private JdbcTemplate jdbcTemplate;

	@RequestMapping("/toLogin")
	public String toLogin() {
		// 表单重复提交的token  
		return "login";
	}

	@RequestMapping("/login")
	public String login(LoginForm form) {
		// 验证用户登录
		System.err.println(form.getUserName() + " >>> " + form.getPassword());
		String sql = "select * from t_user";
		List<Map<String, Object>> listMap = jdbcTemplate.queryForList(sql);
		for (Map<String, Object> map : listMap) {
			System.err.println(map);
		}
		return "layout";
	}

	@RequestMapping("/layout")
	public String layout() {
		System.err.println("--- layout ----");
		return "layout";
	}

}
